prepare-root: avoid double-stacked /sysroot mount
authorDaniel Drake <drake@endlessm.com>
Mon, 2 Feb 2015 21:12:47 +0000 (15:12 -0600)
committerColin Walters <walters@verbum.org>
Wed, 4 Feb 2015 01:28:37 +0000 (20:28 -0500)
commit4f75d4ea0b640dd69f13fd31976d6ddfb42c977a
treea6989a8518ddef6de650c442b053e8ac377f9cbc
parent89a8b9b85a9cf576c43be47f69554e9598eca1ce
prepare-root: avoid double-stacked /sysroot mount

prepare-root works with the mount that has been set up at /sysroot.
It creates a bind-mount within /sysroot (the deployment) and then moves
that mount to /sysroot.

Now we have 2 mounts both at /sysroot, and once we do switch_root, we will
never be able to unmount both of them. I'm not sure if this is ultimately
a kernel bug, but either way, ostree could do a bit more tidying up
after itself.
http://thread.gmane.org/gmane.linux.file-systems/92411

Easy way to reproduce:
1. Boot with rd.break param
2. At initramfs shell, run: ostree-prepare-root /sysroot
3. Observe two /sysroot mounts in /proc/mounts

Fix this by setting up the mounts at /sysroot.tmp, and unmounting the
original /sysroot before our new mount is MS_MOVEd on top of it.
src/switchroot/ostree-prepare-root.c